//===============================================================================
// Microsoft patterns & practices
// Web Client Software Factory
//-------------------------------------------------------------------------------
// Copyright (C) Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//-------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================
using System;
using System.Collections.ObjectModel;

namespace WCSFContrib.PageFlow
{
    /// <summary>
    /// Defines the contract for a page flow instance.
    /// </summary>
    /// <remarks>This interface corresponds to the object side of the Type Object patern. As such it holds the state that is unique to the instance.</remarks>
	public interface IPageFlow
	{
        /// <summary>
        /// Occurs when the execution of a page flow is aborted.
        /// </summary>
		event EventHandler<PageFlowAbortedEventArgs> Aborted;

        /// <summary>
        /// Occurs when the execution of a page flow is started.
        /// </summary>
		event EventHandler<PageFlowEventArgs> Started;

        /// <summary>
        /// Occurs when the execution of a page flow completes.
        /// </summary>
		event EventHandler<PageFlowEventArgs> Completed;

        /// <summary>
        /// Occurs when the execution of a started page flow is suspended.
        /// </summary>
        event EventHandler<PageFlowEventArgs> Suspended;

        /// <summary>
        /// Occurs when the execution of a suspended page flow is resumed.
        /// </summary>
        event EventHandler<PageFlowEventArgs> Resumed;

        /// <summary>
        /// Gets the current page of the page flow.
        /// </summary>
		Page CurrentPage { get; }

        /// <summary>
        /// Gets the page flow definition.
        /// </summary>	
        IPageFlowDefinition Definition { get; }

        /// <summary>
        /// Gets the page flow id.
        /// </summary>
        Guid Id { get; }
        
        /// <summary>
        /// Gets the page flow status.
        /// </summary>
        PageFlowStatus Status { get; }
        
        /// <summary>
        /// Gets the page flow transitions.
        /// </summary>
        ReadOnlyCollection<string> Transitions { get; }
        
        /// <summary>
        /// Gets the page flow user data.
        /// </summary>
       PageFlowState UserData { get; }
       
        /// <summary>
        /// Aborts page flow execution.
        /// </summary>
        /// <param name="redirectToAbortPage">True if the page flow should navigate to the abort page following the abort; false otherwise.</param>
		void Abort(bool redirectToAbortPage);
        
        /// <summary>
        /// Tests whether the page flow can redirect to a given page.
        /// </summary>
        /// <param name="pageName">The name of the target page.</param>
        /// <returns>True if the redirect if possible, false otherwise.</returns>
		bool CanRedirectTo(string pageName);
        
        /// <summary>
        /// Force the page flow to a specific target page.
        /// </summary>
        /// <param name="transitionName">The target page.</param>
        /// <remarks>With this method the developer specifies the target page, overriding the page flow state machine. </remarks>
		void Navigate(string transitionName);
        
        /// <summary>
        /// Redirects the page flow to the current page.
        /// </summary>
		void RedirectToCurrentPage();
        
        /// <summary>
        /// Sets the current page.
        /// </summary>
        /// <param name="pageName">The name of the page.</param>
		void SetCurrentPage(string pageName);
        
        /// <summary>
        /// Starts the page flow.
        /// </summary>
		void Start();
        
        /// <summary>
        /// Suspend the execution of the page flow such that it can be resumed later.
        /// </summary>
		void Suspend();
        
        /// <summary>
        /// Resume the execution of a suspended page flow.
        /// </summary>
        void Resume();
        
        /// <summary>
        /// Changes the status of an executing page flow, marking it as completed.
        /// </summary>
		void Complete();
        
        /// <summary>
        /// Advances the page flow to the next page.
        /// </summary>
        /// <remarks>The page flow state machine determines the next page.</remarks>
		void Next();
	}
}
